package com.leiqichao.backend.config;

import com.leiqichao.backend.interceptor.StatsInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebConfig implements WebMvcConfigurer {
    @Autowired
    private StatsInterceptor statsInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(statsInterceptor)
                .addPathPatterns("/api/**")          // 监控所有API接口
                .excludePathPatterns("/static/**");  // 排除静态资源
    }
}